<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
</head>
<body>
<script>

promise_test(async t => {
  let stream = await navigator.mediaDevices.getUserMedia({audio:true, video:true});
  assert_true(stream.active);
  stream.oninactive = t.step_func_done(() => {
    assert_false(stream.active);
  });

  assert_equals(stream.getAudioTracks().length, 1);
  assert_equals(stream.getVideoTracks().length, 1);
  stream.removeTrack(stream.getAudioTracks()[0]);
  stream.removeTrack(stream.getVideoTracks()[0]);
}, "onInactive called");

promise_test(async t => {
  let stream = await navigator.mediaDevices.getUserMedia({audio:true});

  let new_stream = new MediaStream();
  assert_false(new_stream.active);
  new_stream.onactive = t.step_func_done(() => {
    assert_true(new_stream.active);
  });
  new_stream.addTrack(stream.getAudioTracks()[0]);
}, "onActive called");

</script>
</body>
</html>
